﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using G.Web;
using System.Xml.Serialization;
using System.Runtime.Serialization;

namespace G.WeiBo.WebAPI.Domain
{
    [DataContract]
    public class Message : BaseObject
    {
        static System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("<[^>]+>");
        [DataMember(Name = "created_at")]
        [XmlElement("created_at")]
        public string CreatedTime { get; set; }
        [DataMember(Name = "id")]
        [XmlElement("id")]
        public string Id { get; set; }
        [DataMember(Name = "text")]
        [XmlElement("text")]
        public string Text { get; set; }

        private string thumbnail_pic;
        //public string TextUrl { get; private set; }
        [DataMember(Name = "thumbnail_pic")]
        [XmlElement("thumbnail_pic")]
        public string Thumbnail_pic
        {
            get
            {
                if (APIConfig.IsLoadPic)
                {
                    return thumbnail_pic;
                }
                else
                    return null;
            }
            set
            {
                thumbnail_pic = value;
            }
        }
        [DataMember(Name = "bmiddle_pic")]
        [XmlElement("bmiddle_pic")]
        public string Bmiddle_pic { get; set; }
        [DataMember(Name = "original_pic")]
        [XmlElement("original_pic")]
        public string Original_pic { get; set; }
        [DataMember(Name = "user")]
        [XmlElement("user")]
        public UserInfo User { get; set; }

        private string source;
        [DataMember(Name = "source")]
        //[XmlElement("source")]
        public string Source
        {
            get
            {
                return source;
            }
            set
            {
                if (value != null)
                    source = regex.Replace(value, "");
                else
                    source = value;

            }
        }

        [DataMember(Name = "retweeted_status")]
        [XmlElement("retweeted_status")]
        public Message Retweeted { get; set; }

        private Count count;
        public Count Count
        {
            get
            {
                return count;
            }
            set
            {
                if (count != value)
                {
                    count = value;
                    this.NotifyChanged("Count");
                }
            }
        }

    }

    [DataContract]
    public class Count : BaseObject
    {
        [DataMember(Name = "id")]
        [XmlElement("id")]
        public string ID { get; set; }
        [DataMember(Name = "comments")]
        [XmlElement("comments")]
        public int Comments { get; set; }
        [DataMember(Name = "rt")]
        [XmlElement("rt")]
        public int Rt { get; set; }
    }

    //[DataContract]
    //public class Source : BaseObject
    //{
    //    [DataMember(Name = "a")]
    //    [XmlElement("a")]
    //    public string Name { get; set; }
    //}
}
